package com.education.mymediaplayer.ui.player;

import android.content.Context;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.education.mymediaplayer.R;
import com.education.mymediaplayer.widget.TestVideoView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PlayerActivity extends AppCompatActivity {

    @BindView(R.id.video_test)
    TestVideoView videoTest;
    @BindView(R.id.button_increase_voice)
    Button buttonIncreaseVoice;
    @BindView(R.id.button_decrease_voice)
    Button buttonDecreaseVoice;
    @BindView(R.id.button_increase_brightness)
    Button buttonIncreaseBrightness;
    @BindView(R.id.button_decrease_brightness)
    Button buttonDecreaseBrightness;
    @BindView(R.id.imageview_start)
    ImageView imageviewStart;
    private AudioManager manager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_player);
        ButterKnife.bind(this);
        manager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    }

    @OnClick({R.id.imageview_start, R.id.button_increase_voice, R.id.button_decrease_voice, R.id.button_increase_brightness, R.id.button_decrease_brightness})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.button_increase_voice:
                break;
            case R.id.button_decrease_voice:
                break;
            case R.id.button_increase_brightness:
                changeBrightness();
                break;
            case R.id.button_decrease_brightness:
                decreaseBrightness();
                break;
            case R.id.imageview_start:

                break;
        }
    }

    private void changeBrightness() {
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        Log.d("------------", "当前界面的亮度" + lp.screenBrightness);
        if (lp.screenBrightness < 1) {
            lp.screenBrightness = lp.screenBrightness + 0.1f;
        }
        window.setAttributes(lp);
    }

    private void decreaseBrightness() {
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        Log.d("------------", "当前界面的亮度" + lp.screenBrightness);
        if (lp.screenBrightness > 0) {
            lp.screenBrightness = lp.screenBrightness - 0.1f;
        }
        window.setAttributes(lp);
    }

}
